const namespace = 'XZ-'

const local = {
  set(key, data) {
    window.localStorage.setItem(namespace + key, JSON.stringify(data))
  },
  get(key) {
    const data = window.localStorage.getItem(namespace + key)
    return JSON.parse(data)
  },
  remove(key) {
    window.localStorage.removeItem(namespace + key)
  },
  clear() {
    window.localStorage.clear()
  },
}
const session = {
  set(key, data) {
    window.sessionStorage.setItem(namespace + key, JSON.stringify(data))
  },
  get(key) {
    const data = window.sessionStorage.getItem(namespace + key) || '[]'
    return JSON.parse(data)
  },
  remove(key) {
    window.sessionStorage.removeItem(namespace + key)
  },
  clear() {
    window.sessionStorage.clear()
  },
}

export { local, session }
